################################################################
#                                                              #
# Counterbalancing, Spatial Dependence, and Peer-Group Effects #
#                                                              #
# Political Science Research and Methods                       #
#                                                              #
# Tobias Boehmelt, Andrea Ruggeri, and Ulrich Pilster          #
#                                                              #
# This Version: April 15, 2015                                 #
#                                                              #
# Address Correspondance to: tbohmelt@essex.ac.uk              #
#                                                              #
################################################################


#####################################################################
# Figure 1 (Note: change working directory before running the code) #
#####################################################################

#setwd("/Users/tobiasbohmelt/Dropbox/Coups Spatial/PSRM Paper/2_Final Version/PSRM Replication/")
setwd("C:/Users/tbohmelt/Dropbox/Coups Spatial/PSRM Paper/2_Final Version/PSRM Replication/")

library(maps)
library(rworldmap)
library(foreign)

TAB.Country.CP <- read.dta("Counterbalancing Cross-Section 1970-2014.dta")
colnames(TAB.Country.CP)[1] <- "ISO"
TAB.Country.CP$ISO <- as.character(TAB.Country.CP$ISO)
world.map <- joinCountryData2Map(TAB.Country.CP, joinCode = "ISO3", nameJoinColumn = "ISO")
mapDevice(device="pdf", file="worldmap.pdf")
mapParams <- mapCountryData(world.map, nameColumnToPlot = "effective_number", addLegend = FALSE, colourPalette="white2Black", mapTitle="")
do.call(addMapLegend, c(mapParams, tcl=-0.2, legendWidth = 0.5, legendMar = 2.5, legendLabels="all", legendShrink=0.5, labelFontSize=1))
dev.off()